import api from "@/api/apiServer";
// 获取不合格原因的数据
let badOptions = [];
async function getDictFindByCode(parentCode, key) {
  const res = await api.DictFindByCode({
    parentCode: "ReasonsForProducts",
  });
  badOptions = res.data;
}

getDictFindByCode();

function caseBadReson(id) {
  let arr = badOptions.filter((item) => (item.id = id));
  if (arr.length > 0) {
    return arr[0].dictName;
  } else {
    return "";
  }
}
const columns = [
  {
    title: "投料框码",
    dataIndex: "materialCode",
    key: "materialCode",
    // customRender: (text, record, index) => `${record.level + "级"}`,
    align: "center",
  },
  {
    title: "投料数量",
    dataIndex: "castCount",
    key: "castCount",
    align: "center",
  },
  {
    title: "投料时间",
    dataIndex: "materialTime",
    key: "materialTime",
    align: "center",
  },

  {
    title: "备注",
    dataIndex: "materialRemark",
    key: "materialRemark",
    align: "center",
  },
  {
    title: "操作人",
    dataIndex: "operator",
    key: "operator",
    align: "center",
  },
];

const produce = [
  {
    title: "产出框码",
    dataIndex: "outputCode",
    key: "outputCode",
    // customRender: (text, record, index) => `${record.level + "级"}`,
    align: "center",
  },
  {
    title: "合格数量",
    dataIndex: "outputCount",
    key: "outputCount",
    align: "center",
  },
  {
    title: "不合格数量",
    dataIndex: "badCount",
    key: "badCount",
    align: "center",
  },
  {
    title: "不合格原因",
    dataIndex: "badCountReason",
    key: "badCountReason",
    align: "center",
    customRender: (text, record, index) => {
      return caseBadReson(text);
    },
  },
  {
    title: "产出时间",
    dataIndex: "outputTime",
    key: "outputTime",
    align: "center",
  },
  {
    title: "备注",
    dataIndex: "outputRemark",
    key: "outputRemark",
    align: "center",
  },
  {
    title: "操作人",
    dataIndex: "operator",
    key: "operator",
    align: "center",
  },
];

export { columns, produce };
